; If the printer hasn't been homed, home it

if {global.idex} = 0
	if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
		G28				; home all
elif {global.idex} = 1
	if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed || !move.axes[3].homed
		G28				; home all

T0					; select primary hotend
G1 Z30 				; move to Z=30
G1 X100 Y100 F3000	; move to X100, Y100
G4 P0 				; wait for all movements to complete
M300 S1111 P333		; beep

M291 S2 R"Primary blower fan testing" P"The part cooling fan will spin for 10 seconds. Verify that it works"
M106 P0 S255		; turn part cooling fan at 100%
G4 S10				; wait 10 seconds
M106 P0 S0			; turn part cooling off
G4 P0				; wait
M300 S1111 P333		; beep
M291 S2 R"Primary blower fan testing" P"Did the part cooling turn on and off as it should?"

M291 S2 R"Heater testing" P"In the next step, the hotend will heat up to 210c."
if {global.generation} = 5
	M291 S2 R"Heater testing" P"Check that the heatsink fan turns on when the temperature rises above 45c"
elif {global.generation} = 4
	M291 S2 R"Heater testing" P"Check that the heatsink fan turns on when the temperature rises above 45c"

M570 H0 P50 T50		; Extend the heater H0 fault timeout to 50 seconds for testing
M568 P0 S210 R0		; set temperature to 210c
T0					; select primary hotend
M116 P0				; wait for P0 to reach target temp
M570 H0 P5 T15		; return the the heater H0 fault settings to default
M300 S1111 P333		; beep
M291 S2 R"Heater testing" P"Did the hotend heat up to 210c as it should?"

M291 S2 R"Extruder testing" P"The extruder will now extrude filament for 10 seconds"
M83					; relative extruder moves
G1 E30 F180			; extrude 30mm of filament over 10 seconds
G4 P0				; wait for the moves to finish   
M300 S1111 P333		; beep
M568 P0 S0 R0		; set temperature to 0c
T-1					; deselect primary hotend
M300 S1111 P333		; beep
M291 S2 R"Extruder testing" P"Did the extruder correctly extrude filament? If not, check the guide for troubleshooting"

M291 S3 R"You may proceed to the next step" P"Primary hotend verification has been completed" ;
M568 P0 S0 R0 A0
M18					; release stepper motors